package cn.circle.system.model;

import java.io.Serializable;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.criteria.CriteriaBuilder.In;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.validator.constraints.NotEmpty;

import com.sun.jmx.snmp.Timestamp;

import cn.circle.system.model.SysDepartment;
/**
 * 商品信息类 
 * 对应数据库表：COMMODITY_INFO
 * 作者：
 * 时间：
 */
@Entity
@Table(name="COMMODITY_INFO")
@DynamicInsert(true)
@DynamicUpdate(true)
public class CommodityInfo implements Serializable{
	private static final long serialVersionUID = -6288383278071844189L;
	/**
	 * 商品信息（COMMODITY_INFO）
	 * 
	 *  COMMODITY_ID         bigint not null,
   NAMES                varchar(30) not null,
   SUMMARY              varchar(300) not null,
   PRICE                double not null,
   CATEGORY_ID          int,
   NUMBER               int not null comment '商品剩余',
   ORDER_COUNT          int,
   VIEW_COUNT           int comment '客户浏览次数',
   PHOTO                varchar(300),
   STATUS               tinyint not null comment '9在售，1售空，0禁用',
   CREATE_USER_ID       int,
   CREATE_TIME          timestamp not null default CURRENT_TIMESTAMP,
   UPDATE_USERID        int,
   UPDATE_TIME          datetime,
   primary key (COMMODITY_ID)
);
	 */
	private Long commodityId;  //商品编号
	private String names;    //名称
	private String summary;  //描述
	private Double price;    //价格
	private Double nativePrice; //原价
/*	private Integer categoryId;  //类别
*/	private CommodityCategory commodityCategory;
	private Integer number;  //库存
//	private Integer depId;  //部门
//	private SysDepartment sysDepartment;
	private Integer orderCount;   //订单数
	private Integer viewCount;  //浏览次数
	private String photo;    //图片
	private Byte status;     //状态
	private Integer createUserId;    //创建者
	private java.sql.Timestamp createTime;   //创建时间
	private Integer updateUserId;   //修改者
	private Date updateTime;    //修改时间
	@Id
	@Column(name = "COMMODITY_ID",unique = true,nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)		//自增长
	public Long getCommodityId() {
		return commodityId;
	}
	public void setCommodityId(Long commodityId) {
		this.commodityId = commodityId;
	}
	@NotEmpty
	@Column(name = "NAMES")
	public String getNames() {
		return names;
	}
	public void setNames(String names) {
		this.names = names;
	}
	@NotEmpty
	@Column(name = "SUMMARY")
	public String getSummary() {
		return summary;
	}
	public void setSummary(String summary) {
		this.summary = summary;
	}
	@Column(name = "PRICE")
	public Double getPrice() {
		return price;
	}
	public void setPrice(Double price) {
		this.price = price;
	}
	@ManyToOne(targetEntity =CommodityCategory.class)
	@JoinColumn(name = "CATEGORY_ID")
	@OrderBy("CATEGORY_ID")
    public CommodityCategory getCommodityCategory() {
		return commodityCategory;
	}
	public void setCommodityCategory(CommodityCategory commodityCategory) {
		this.commodityCategory = commodityCategory;
	}
/*	@Column(name = "CATEGORY_ID")
	public Integer getCategoryId() {
		return categoryId;
	}
	public void setCategoryId(Integer categoryId) {
		this.categoryId = categoryId;
	}*/
	@NotNull
	@Column(name = "NUMBER")
	public Integer getNumber() {
		return number;
	}
	public void setNumber(Integer number) {
		this.number = number;
	}
	@Column(name = "ORDER_COUNT", columnDefinition = "int default 0")
	public Integer getOrderCount() {
		return orderCount;
	}
	public void setOrderCount(Integer orderCount) {
		this.orderCount = orderCount;
	}
	@Column(name = "VIEW_COUNT", columnDefinition = "int default 0")
	public Integer getViewCount() {
		return viewCount;
	}
	public void setViewCount(Integer viewCount) {
		this.viewCount = viewCount;
	}
	@Column(name = "PHOTO")
	public String getPhoto() {
		return photo;
	}
	public void setPhoto(String photo) {
		this.photo = photo;
	}
	@NotNull
	@Column(name = "STATUS", columnDefinition = "tinyint default 9")
	public Byte getStatus() {
		return status;
	}
	public void setStatus(Byte status) {
		this.status = status;
	}
	@Column(name = "CREATE_USER_ID")
	public Integer getCreateUserId() {
		return createUserId;
	}
	public void setCreateUserId(Integer createUserId) {
		this.createUserId = createUserId;
	}
	
	@Column(name = "CREATE_TIME",columnDefinition = "timestamp not null default CURRENT_TIMESTAMP")
	public java.sql.Timestamp getCreateTime() {
		return createTime;
	}
	public void setCreateTime(java.sql.Timestamp createTime) {
		this.createTime = createTime;
	}
	@Column(name = "UPDATE_USERID")
	public Integer getUpdateUserId() {
		return updateUserId;
	}
	public void setUpdateUserId(Integer updateUserId) {
		this.updateUserId = updateUserId;
	}
	@Column(name = "UPDATE_TIME")
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	
	/*@ManyToOne(targetEntity = SysDepartment.class)
	@JoinColumn(name = "DEP_ID")
	public SysDepartment getSysDepartment() {
		return sysDepartment;
	}
	public void setSysDepartment(SysDepartment sysDepartment) {
		this.sysDepartment = sysDepartment;
	}*/
	@Column(name = "NATIVE_PRICE")
	public Double getNativePrice() {
		return nativePrice;
	}
	public void setNativePrice(Double nativePrice) {
		this.nativePrice = nativePrice;
	}
	

}
